//
//  SayHiViewController.m
//  ChatForHot
//
//  Created by FLY on 2018/10/19.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "SayHiViewController.h"
#import "SayHelloView.h"
#import "UserInfoController.h"
@interface SayHiViewController ()<SayHelloDelegate>

@property (nonatomic, strong) SayHelloView *HOTCHATsayHelloView;

@end

@implementation SayHiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor clearColor];
    
    
}
- (void)HOTCHATInsertSubViews{
    
    
    [self.view addSubview:self.HOTCHATsayHelloView];
    
    [self.HOTCHATsayHelloView mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
    }];
    
    self.HOTCHATsayHelloView.dataArr = self.dataArr;
}

- (SayHelloView *)HOTCHATsayHelloView{
    
    if (_HOTCHATsayHelloView == nil) {
        
        _HOTCHATsayHelloView = [[SayHelloView alloc]init];
        _HOTCHATsayHelloView.delegate = self;
        
    }
    return _HOTCHATsayHelloView;
}
// sayhi delegate
- (void)HOTCHATsayHello{
    
    for (UserInfoModel *model in self.dataArr) {
        
        [NetWorkTool HOTCHATsendMessage:@"Hi" toUser:model.IMUser];
    }
    [self HOTCHATopenTheMessages];
    [self dismissViewControllerAnimated:NO completion:nil];
}
- (void)HOTCHATclcikTheUserWithIndex:(NSInteger)index{
    
    UserInfoModel *model = self.dataArr[index];
    UserInfoController *userVC = [[UserInfoController alloc]init];
    userVC.IMID = model.IMUser;
    userVC.accountId = model.accountid;
    userVC.userInfoModel = model;
    userVC.isSayhello = YES;
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:userVC];
    
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)HOTCHATopenTheMessages{
    
    if (HOTCHATAPPINFO.sex.integerValue == 0) {
        //is women not need
        return;
    }
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:HOTCHATAPPINFO.accountid forKey:@"accountid"];
    
    [NetWorkTool HOTCHATRequestWithStringURL:OPENSENDMESSAGES_URL progress:^(NSProgress * _Nonnull progress) {
        
    } RequestWay:@"GET" Parma:dic SuccessBlock:^(BOOL isSucess, NSDictionary * _Nonnull resultDictionary) {
       
        NSLog(@"say hi yes");
    } FailureBlock:^(NSError * _Nonnull error) {
        NSLog(@"say hi no");
    }];
}
@end
